package com.personal.portal.admin.controller;

import com.personal.portal.common.entity.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * 健康检查控制器
 * 
 * @author zhanghui
 * @version 1.0.0
 * @since 2025-11-10
 */
@Tag(name = "系统监控", description = "系统健康检查和信息接口")
@RestController
@RequestMapping("/admin/health")
public class HealthController {

    /**
     * 系统健康检查
     */
    @Operation(summary = "系统健康检查", description = "检查系统运行状态和基本信息")
    @GetMapping("/check")
    public Result<Map<String, Object>> healthCheck() {
        Map<String, Object> data = new HashMap<>();
        data.put("status", "UP");
        data.put("timestamp", LocalDateTime.now());
        data.put("service", "personal-portal-backend");
        data.put("version", "1.0.0");
        data.put("javaVersion", System.getProperty("java.version"));
        data.put("osName", System.getProperty("os.name"));
        data.put("osArch", System.getProperty("os.arch"));
        
        return Result.success(data);
    }

    /**
     * 系统信息
     */
    @Operation(summary = "系统信息", description = "获取系统详细信息和版本信息")
    @GetMapping("/info")
    public Result<Map<String, Object>> systemInfo() {
        Map<String, Object> data = new HashMap<>();
        data.put("application", "个人信息管理系统");
        data.put("description", "个人信息展示与管理系统后端API");
        data.put("version", "1.0.0");
        data.put("author", "zhanghui");
        data.put("buildTime", "2025-11-10");
        
        return Result.success(data);
    }
}